package collect.taobao.util;   
  
import java.security.MessageDigest;   
  
public class Md5   
{   
   public static String encryption(String string)    
   {   
       char hexDigits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd',   
        'e', 'f' };   
        try {   
            byte[] bytes = string.getBytes();   
            MessageDigest messageDigest = MessageDigest.getInstance("MD5");   
            messageDigest.update(bytes);   
            byte[] updateBytes = messageDigest.digest();   
            int len = updateBytes.length;   
            char md5Char[] = new char[len * 2];   
            int j = 0;   
            for (int i = 0; i < len; i++) {   
                byte byte0 = updateBytes[i];   
                md5Char[j++] = hexDigits[byte0 >>> 4 & 0x0f];   
                md5Char[j++] = hexDigits[byte0 & 0x0f];   
            }   
        return new String(md5Char);   
        } catch (Exception e) {   
        return null;   
        }   
    }   
    
    public static void main(String[] arg)   
    {   
        System.out.println(Md5.encryption("abc"));   
    }   
  
}  
